﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="/favicon.ico" >
	<link rel="Shortcut Icon" href="/favicon.ico" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5shiv.js"></script>
	<script type="text/javascript" src="lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<!--/meta 作为公共模版分离出去-->

	<title>修改商品</title>
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-admin-role-add" enctype="multipart/form-data">
		<input type="hidden" name="id" value="{$goods['g_id']}">
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;"><span class="c-red">*</span>商品名称：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" value="{$goods['g_name']}" placeholder="" name="g_name" id="g_name">
			</div>
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">排序（倒叙）：</label>
			<div class="formControls col-xs-8 col-sm-3">
				<input type="text" class="input-text" value="{$goods['g_sort']}" placeholder="" name="g_sort">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">分类：</label>
			<div class="formControls col-xs-8 col-sm-3"> <span class="select-box">
				<select class="select" size="1" name="gt_id">
					{volist name="type1" id="v"}
						<option value="{$v['gt_id']}" disabled="disabled">{$v['gt_name']}</option>
						{volist name="type2" id="vv"}
							{if condition="$vv['gt_pid'] eq $v['gt_id']"}
							<option value="{$vv['gt_id']}" disabled="disabled">├─{$vv['gt_name']}</option>
								{volist name="type3" id="vvv"}
									{if condition="$vvv['gt_pid'] eq $vv['gt_id']"}
									<option value="{$vvv['gt_id']}" {if condition="$goods['gt_id'] eq $vvv['gt_id']"}selected{/if}>├─├─{$vvv['gt_name']}</option>
									{/if}
								{/volist}
							{/if}
						{/volist}
					{/volist}
				</select>
				</span>
			</div>
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">品牌：</label>
			<div class="formControls col-xs-8 col-sm-3"> <span class="select-box">
				<select class="select" size="1" name="gb_id">
					<option value="0" {if condition="$goods['gb_id'] eq 0"}selected{/if}>无品牌产品</option>
					{volist name="brand" id="v"}
						<option value="{$v['gb_id']}" {if condition="$goods['gb_id'] eq $v['gb_id']"}selected{/if}>{$v['gb_name']}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">是否上架：</label>
			<div class="formControls col-xs-8 col-sm-3 skin-minimal">
				<div class="radio-box">
					<input name="g_status" type="radio" value="1" {if condition="$goods['g_status'] eq 1"}checked{/if}>
					<label for="sex-1">上架</label>
				</div>
				<div class="radio-box">
					<input name="g_status" type="radio" value="2" {if condition="$goods['g_status'] neq 1"}checked{/if}>
					<label for="sex-2">下架</label>
				</div>
			</div>
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">是否首页推荐：</label>
			<div class="formControls col-xs-8 col-sm-3 skin-minimal">
				<div class="radio-box">
					<input name="g_is_index_recommen" type="radio" value="1" {if condition="$goods['g_is_index_recommen'] eq 1"}checked{/if}>
					<label for="sex-1">首页推荐</label>
				</div>
				<div class="radio-box">
					<input name="g_is_index_recommen" type="radio" value="2" {if condition="$goods['g_is_index_recommen'] neq 1"}checked{/if}>
					<label for="sex-2">不推荐</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">标签：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<dl class="permission-list">

					<dd>
						<dl class="cl permission-list0">
							<dd style="margin-left:0px;">
								{volist name="label" id="v"}
								<label class="">
									<input type="checkbox" name="label[]" value="{$v['gl_id']}" {if in_array($v['gl_id'],$goods_label)}checked{/if} id="user-Character-0-0-0">
									{$v['gl_name']}
								</label>
								{/volist}
								<!-- <label class="c-orange"><input type="checkbox" name="permissions[]" value="7"  id="user-Character-0-0-5"> 只能操作自己发布的</label> -->
							</dd>
						</dl>
					</dd>
				</dl>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;"><span class="c-red">*</span>商品规格(至少一个)：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="mt-20">
					<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
						<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive dataTable no-footer" id="DataTables_Table_0" role="gsid" aria-describedby="DataTables_Table_0_info">
							<thead>
							<tr class="text-c">
								<!-- <th class="sorting_asc" tabindex="0" rowspan="1" colspan="1" style="width: 25px;"  width="25"><input type="checkbox" name="" value=""></th> -->
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 25%;"  width="40">规格</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">售价</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">库存</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">原价</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 13%;"  width="40">重量（kg）</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">乘数</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">单位</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 8%;"  width="40">排序</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 13%;"  width="40">操作</th>
							</tr>
							</thead>
							<tbody>
							{volist name="norm" id="v"}
							<tr class="text-c odd" role="row">
								<!-- <td class="sorting_1"><input type="checkbox" value="" name=""></td> -->
								<td><input type="text" class="input-text" value="{$v['gn_name']}" placeholder="" name="gn_name[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_price']}" placeholder="" name="gn_price[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_stock']}" placeholder="" name="gn_stock[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_old_price']}" placeholder="" name="gn_old_price[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_weight']}" placeholder="" name="gn_weight[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_details_number']}" placeholder="" name="gn_details_number[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_details_unit']}" placeholder="" name="gn_details_unit[]"></td>
								<td><input type="text" class="input-text" value="{$v['gn_sort']}" placeholder="" name="gn_sort[]"></td>
								<td><a style="text-decoration:none;margin-left:4px;" onclick="_ajax('{:Url('admin/Goods/norm_del')}',{$v['gn_id']},'删除',this)" href="javascript:void(0);" title="删除">删除</a><input name="gn_ids[]" hidden value="{$v['gn_id']}"><input name="old_price[]" hidden value="{$v['gn_price']}"></td>

							</tr>
							{/volist}
							<tr class="text-c odd" role="row" id="add_norm">
							</tr>
							</tbody>
						</table>
					</div>
				</div>
				<button type="button" class="btn btn-success radius" style="margin-top: 10px;" onclick="add_norm();"><i class="icon-ok"></i> 增加一个规格</button>
			</div>

		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">原主图：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<img src="{$goods['g_img']}" style="width: 50px;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">主图（不修改不添加）：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="mt-20">
					<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
						<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive dataTable no-footer" id="DataTables_Table_0" role="gsid" aria-describedby="DataTables_Table_0_info">

							<tbody>
							<tr class="text-c odd" role="row">
								<!-- <td class="sorting_1"><input type="checkbox" value="" name=""></td> -->
								<td>
									<div class="formControls col-xs-8 col-sm-5"> <span class="btn-upload form-group">
										<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
										<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
										<input type="file" multiple name="g_img" class="input-file">
										</span>
									</div>
								</td>
							</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align:right;">轮播图（不传则为默认图片）：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="mt-20">
					<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
						<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive dataTable no-footer" id="DataTables_Table_0" role="gsid" aria-describedby="DataTables_Table_0_info">
							<thead>
							<tr class="text-c">
								<!-- <th class="sorting_asc" tabindex="0" rowspan="1" colspan="1" style="width: 25px;"  width="25"><input type="checkbox" name="" value=""></th> -->
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 10%;"  width="40">图片</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 20%;"  width="40">地址</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 10%;"  width="80">修改</th>
								<th class="sorting" tabindex="0"  rowspan="1" colspan="1" style="width: 5%;"  width="40">操作</th>
							</tr>
							</thead>
							<tbody>
							{volist name="img" id="v"}
							<tr class="text-c odd" role="row">
								<td><img src="{$v['gi_img']}" style="width: 50px;"></td>
								<td><a href="{$v['gi_img']}" target="_blank">{$v['gi_img']}</a></td>
								<!-- <td class="sorting_1"><input type="checkbox" value="" name=""></td> -->
								<td>
									<div class="formControls col-xs-8 col-sm-9"> <span class="btn-upload form-group">
										<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
										<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
										<input type="file" multiple name="gi_img_{$v['gi_id']}" class="input-file">
										</span>
									</div>
								</td>
								<td><a style="text-decoration:none;margin-left:4px;" onclick="_ajax('{:Url('admin/Img/img_real_del')}',{$v['gi_id']},'删除',this)" href="javascript:void(0);" title="删除">删除</a><input name="gi_ids[]" hidden value="{$v['gi_id']}"></td>
							</tr>
							{/volist}
							<tr class="text-c odd" role="row" id="add_img">
							</tr>
							</tbody>
						</table>
					</div>
				</div>
				<button type="button" class="btn btn-success radius" style="margin-top: 10px;" onclick="add_img();"><i class="icon-ok"></i> 增加一张轮播图</button>
			</div>

		</div>
		<div class="row cl">
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">详细内容：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<script id="editor" type="text/plain" style="width:100%;height:400px;">{$goods['g_content']}</script>
            </div>
		</div>
                <!--<div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3" style="text-align:right;">产地：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" name="g_origin_place">
                    </div>
                    </div>
                    <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3" style="text-align:right;">生成厂家：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" name="g_manufactor">
                    </div>
                    </div>
                    <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3" style="text-align:right;">存储方式：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" name="g_storage">
                    </div>
                    </div>
                    <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3" style="text-align:right;">保质期：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" name="g_expiry">
                    </div>
                    </div>
                    <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-3" style="text-align:right;">备注：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="g_remarks" cols="" rows="" class="textarea"  placeholder="备注" dragonfly="true"></textarea>

                    </div>
                    </div>-->
                    <!-- col-sm-3 控制长度 -->
                    <div class="row cl">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button type="submit" class="btn btn-success radius"><i class="icon-ok"></i> 确定</button>
                </div>
                </div>
                </form>
                </article>

                <!--_footer 作为公共模版分离出去-->
                <script type="text/javascript" src="__PUBLIC__/admin/lib/jquery/1.9.1/jquery.min.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/layer/2.4/layer.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui/js/H-ui.min.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

				<!--请在下方写此页面业务相关的脚本-->
				<script type="text/javascript" src="__PUBLIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/webuploader/0.1.5/webuploader.min.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
				<script type="text/javascript" src="__PUBLIC__/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
				<script type="text/javascript">
                    $(function(){
                        var ue = UE.getEditor('editor');
                        $('.skin-minimal input').iCheck({
                            checkboxClass: 'icheckbox-blue',
                            radioClass: 'iradio-blue',
                            increaseArea: '20%'
                        });

                        $("form").validate({
                            rules:{
                                g_name:{
                                    required:true,
                                    minlength:2,
                                    maxlength:100
                                }

                            },
                            onkeyup:false,
                            focusCleanup:true,
                            success:"valid",
                            submitHandler:function(form){
                                //form提交事件

                                var url=$("form:eq(0)").attr("action");
                                var formData = new FormData($('form')[0]);
                                $.ajax({
                                    type: 'post',
                                    url: url,
                                    data: formData,
                                    cache: false,
                                    processData: false,
                                    contentType: false,
                                }).success(function (data) {
                                    if(data.code==1){
                                        layer.msg(data.msg,{icon: 6,time:1000});
                                        setTimeout(function () {
                                            parent.location.reload();
                                        }, 1010);
                                    }else{
                                        layer.msg(data.msg,{icon: 5,time:1000});
                                    }
                                }).error(function () {
                                    layer.msg('上传失败',{icon: 5,time:1000});
                                });
                                //ajax上传：包括图片
                                return false;
                            }
                        });
                    });
                    function add_norm(){
                        var str='<tr class="text-c odd" role="row"><td><input type="text" class="input-text" value="" placeholder="" name="gn_name[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_price[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_stock[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_old_price[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_weight[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_details_number[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_details_unit[]"></td><td><input type="text" class="input-text" value="" placeholder="" name="gn_sort[]"></td><td><a style="text-decoration:none;margin-left:4px;" onclick="del_line(this)" href="javascript:void(0);" title="删除">删除</a><input name="gn_ids[]" hidden value="0"><input name="old_price[]" hidden value="0"></td></tr>';
                        $("#add_norm").before(str);
                    }

                    function add_img(){
                        var str='<tr class="text-c odd" role="row"><td></td><td></td><td><div class="formControls col-xs-8 col-sm-9"> <span class="btn-upload form-group"><input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px"><a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a><input type="file" multiple name="gi_img[]" class="input-file"></span></div></td><td><a style="text-decoration:none;margin-left:4px;" onclick="del_line(this)" href="javascript:void(0);" title="删除">删除</a><input name="gi_ids[]" hidden value="0"></td></tr>';
                        $("#add_img").before(str);
                    }
                    function del_line(e){
                        $(e).parents("tr").remove();
                    }
                    //ajax
                    function _ajax(url,id,str,e){
                        layer.confirm('确认要'+str+'吗？',function(index){
                            $.post(url,{'id':id},function(data){
                                if(data.code==1){
                                    layer.msg(data.msg,{icon: 1,time:1500});
                                    setTimeout(function(){
                                        $(e).parents("tr").remove();
                                    });
                                }else{
                                    layer.msg(data.msg,{icon: 2,time:1500});
                                }
                            });
                        });
                        return false;
                    }
				</script>

				<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>